<% 
 /**
  * @Class Name : typeOne.jsp
  * @Description : 
  * @Modification Information
  * @
  * @  수정일              수정자                   수정내용
  * @ -------    --------    ---------------------------
  * @ 20xx.0x.xx              최초 생성
  *
  *  @author 
  *  @since 2013.04.10
  *  @version 1.0
  *  @Environment : apache-tomcat6, JavaSE JSK 1.6, ORACLE 10G, 전자정부프레임웍
  *
  */
%> 
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@page import="java.util.Date"%>

<c:set var="date" value="<%=new Date() %>"/> 
<c:set var="datepicker" value="<%=new Date() %>"/>  

<fmt:formatDate var ="today1" value="${date }" type="date" pattern="yyyyMMdd"/>
<fmt:formatDate var ="today2" value="${datepicker }" type="date" pattern="yyyyMMdd"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>  
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 
<script type="text/javascript">
$(document).ready(function() {    
	$("#date").datepicker({
		minDate:new Date(),
		dateFormat: "yy-mm-dd",
		onClose: function(selectedDate){
			$("#datepicker").datepicker("option", "minDate", selectedDate);
		}
	});
	
	$( "#datepicker" ).datepicker({
		minDate:new Date(),
		dateFormat: "yy-mm-dd",
		onClose: function(selectedDate){
			$("#date").datepicker("option", "maxDate", selectedDate);
		}
	});
	
	$("#name").focus(function(){returnMessage();});
	$("#name").blur(function(){returnMessage2();});
	$("#btnRequest").click(function(){inputcheck();});
	$("#btnClose").click(function(){window.close();});
	$("#btnAdd").click(function(){openAppro();});
	$("#lblCheck").click(function(){window.open('./checkDateForm.do','chkDatePopup','width=550px height=600px; ');});
}); 

function openAppro(){
	window.open("/${initParam.context_root}/typeThree2Result.do","appro",
			"width=600px, height=450px,  menubar=no, status=yes, realzable=no, location=no, scrollbars=yes, toolbar=no, resizable=yes");
}

function inputcheck(){
	if(inputRequestBoard.calendarStart.value==""){
		alert("사용 시작날짜를 입력해주세요");
		return;
	}
	if(inputRequestBoard.calendarEnd.value==""){
		alert("사용 마지막날짜를 입력해주세요");
		return;
	}
	if(inputRequestBoard.sau.value==""){
		alert("사유를 입력해주세요");
		return;
	}
	if(inputRequestBoard.phone.value==""){
		alert("연락처를 입력해주세요");
		return;
	}
	if(inputRequestBoard.approName.value==""){
		alert("결재자를 입력해주세요");
		return;
	}
	var flag = window.confirm("작성한 대로 신청하시겠습니까?");
	if(flag){
		$("#inputRequestBoard").submit();
	}
}
function returnMessage(){
	var font = document.createElement("font");
	font.color="red";
	var txt = document.createTextNode("신청자 변경시 재접속하세요.");
	var space = document.getElementById("message");
	space.appendChild(font).appendChild(txt);
}

function returnMessage2(){
	var space = document.getElementById("message");
	space.removeChild(space.lastChild);
}

function winResize() {
	var Dwidth = parseInt(document.body.scrollWidth);
	var Dheight = parseInt(document.body.scrollHeight);
	var divEl = document.createElement("div");
	divEl.style.position = "absolute";
	divEl.style.left = "0px";
	divEl.style.top = "0px";
	divEl.style.width = "100%";
	divEl.style.height = "100%";

	document.body.appendChild(divEl);

	window.resizeBy(Dwidth - divEl.offsetWidth+10, Dheight
			- divEl.offsetHeight+10);
	document.body.removeChild(divEl);
}

</script>

<title>복무신청</title>
</head>
<body onload="winResize()">
<form id=inputRequestBoard name="inputRequestBoard" action="/${initParam.context_root }/typeOneSave.do" method="post" enctype="multipart/form-data">
	<br> 복무신청
	<div align="right"><input type="button" onclick="location.href='/${initParam.context_root }/typeOneList.do'" value="신청내역"> </div>
	<hr>
	<table cellpadding="4">
		<tr>
			<td>신청자</td>
			<td>
			<c:choose>
				<c:when test="${not empty sessionScope.user }">
					<input type="text" name="name" value="${user.name }" readonly="readonly" title="신청자 변경시 재접속하세요." >
					&nbsp;<span id="message"></span>
				</c:when>
				<c:otherwise>
					<font color="red" style="font-weight: bold; font-style: italic;"><input type="text" name="name" value="${user.name}"> 로그인을 먼저 해주세요.</font>
				</c:otherwise>
			</c:choose>
			</td>
			<td></td>
		</tr>
		<tr>
			<td>종별</td>
			<td colspan="2">
			<select name="jongbyul"> 
					<option value="1">1종</option>
					<option value="2">2종</option>
					<option value="3">3종</option>
					<option value="4">4종</option>
					<option value="5">5종</option>
			</select></td>
		</tr>
		<tr>
			<td>사용기간</td>
			<td colspan="2">
			<input type="text" value="${today }" name="calendarStart" id="date" title="시작일을 선택하세요.">~<input type="text" id="datepicker" name="calendarEnd" title="종료일을 선택하세요." /></td>
		<tr>
		<tr>
			<td>사용시간</td>
			<td colspan="2"><select name="timeStart">
					<c:forEach var = "start_hour" begin = "1" end="24" step="1">
						<option value="${start_hour }">${start_hour }</option>
					</c:forEach>
			</select> <select name="startMinute">
					<c:forEach var = "start_minute" begin = "0" end="59" step="1">
						<option value="${start_minute }">${start_minute }</option>
					</c:forEach>
			</select> &nbsp;~ &nbsp; <select name="timeEnd">
					<c:forEach var = "end_hour" begin = "1" end="24" step="1">
						<option value="${end_hour }">${end_hour }</option>
					</c:forEach>
			</select> <select name="endMinute">
					<c:forEach var = "end_minute" begin = "0" end="59" step="1">
						<option value="${end_minute }">${end_minute }</option>
					</c:forEach>
			</select></td>
			
		</tr>
		<tr>
			<td>신청일 확인</td>
			<td colspan="2">
			<label id ="lblCheck" style="cursor: pointer;" >
			<font color="darkblue" style="text-decoration: underline;" title="신청일자를 확인합니다.">[신청일(시간) 확인]</font></label>
			</td>
		</tr>
		<tr>
			<td>사유</td>
			<td colspan="2"><input type="text" name="sau"></td>
		</tr>
		<tr>
			<td>연락처</td>
			<td colspan="2"><input type="text" name="phone"></td>
		</tr>
		<tr>
			<td>비고</td>
			<td colspan="2"><input type="text" name="bigo"></td>
		</tr>
		<tr>
			<td>첨부파일</td>
			<td colspan="2"><input type="file" name="picture" value="첨부하기" title="사진을 첨부합니다."/></td>
		</tr>
		<tr>
			<td>결재자</td>
			<td><input type="text" name="approName" value=" ">&nbsp;
			
			<input type="button" id ="btnAdd" title="추가하기"  value="추가">
			</td>
		</tr>
	</table>

	<hr>

	<div align="right">
	<button id ="btnRequest" title="신청하기"  >신청</button>
	<button id ="btnClose"  title="창을 닫습니다.">닫기</button>
</div>
</form>
</body>
</html>